/*
 *  Copyright (C) 2009  Peter Kist & Jan Ripke
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "StateFactory.h"

#include "states/ExitState.h"
#include "states/CreditsState.h"
#include "states/GameState.h"
#include "states/MainState.h"
#include "states/SettingsState.h"

#include <Util/Logger.h>

namespace gs = galaxy::logic::gamestate::states;


namespace galaxy {
    namespace logic {
        namespace gamestate {

            StateFactory::StateFactory(void)
            {
            }

            StateFactory::~StateFactory(void)
            {
            }

            StatePtr StateFactory::createState(logic::State::Name& stateName) {
                StatePtr state;

                LOG_INFO (std::string ("creating logic state ") + stateName);

                if (stateName == logic::State::c_MainMenu) {
                    boost::shared_ptr<states::MainState> mainState (new states::MainState());
                    state = mainState;
                }
                if (stateName == logic::State::c_Credits) {
                    boost::shared_ptr<states::CreditsState> creditsState (new states::CreditsState());
                    state = creditsState;
                }
                if (stateName == logic::State::c_Settings) {
                    boost::shared_ptr<states::SettingsState> settingsState (new states::SettingsState());
                    state = settingsState;
                }
                if (stateName == logic::State::c_SinglePlayer) {
                    boost::shared_ptr<states::GameState> gameState (new states::GameState());
                    gameState->setGameType(states::SINGLE_PLAYER);
                    state = gameState;
                }
                if (stateName == logic::State::c_Exit) {
                    boost::shared_ptr<states::ExitState> exitState (new states::ExitState());
                    state = exitState;
                }

                if (! state) {
                    LOG_ERROR (std::string("unknown state '") + stateName + "'");
                }

                return state;
            }

        } // namespace gamestate
    } // namespace logic
} // namespace galaxy
